Package com.cisco.pt.ptmp.impl
Class PacketTracerReadWorkerImpl
java.lang.Object
java.lang.Thread
com.cisco.pt.ptmp.impl.PacketTracerReadWorkerImpl
- All Implemented Interfaces:
PacketTracerReadWorker,Runnable
Provides a thread to read response messages and asynchronous (out-of-band) event
messages sent by Packet Tracer.
- Author:
- packettracerexapps@external.cisco.com
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Pipelineprotected PacketTracerSessionprotected booleanFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionPacketTracerReadWorkerImpl(PacketTracerSession session, Pipeline pipeline) Create a newPacketTracerReadWorkerImplthat will use the given Pipeline for reading messages from Packet Tracer. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddiscardUnknownMessage(LTV ltv) Note a read message that's neither a response nor an event.protected voidNote a response message that had no matching requester.Returns the pipeline used for readinggetResponse(LTV ltv) Blocks the current Thread until a response message for ltv is received from Packet Tracerprotected voidreadKeepAlive(LTV ltv) voidregisterRequest(LTV ltv) Creates an entry that will be matched with any response to the ltv from Packet Tracervoidrun()This is the body of the Thread, in which this object does its work.voidCauses this worker to stop running.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yieldMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.cisco.pt.ptmp.PacketTracerReadWorker
start
-
Field Details
-
session
-
pipeline
-
waiters
-
shouldStop
protected volatile boolean shouldStop
-
-
Constructor Details
-
PacketTracerReadWorkerImpl
Create a newPacketTracerReadWorkerImplthat will use the given Pipeline for reading messages from Packet Tracer.- Parameters:
session- ThePacketTracerSessionthat created this object. Events received from Packet Tracer will be returned to thesessionfor further processing.pipeline- The read pipeline to use
-
-
Method Details
-
getPipeline
Description copied from interface:PacketTracerReadWorkerReturns the pipeline used for reading- Specified by:
getPipelinein interfacePacketTracerReadWorker- Returns:
- The underlying pipeline
-
registerRequest
Description copied from interface:PacketTracerReadWorkerCreates an entry that will be matched with any response to the ltv from Packet Tracer- Specified by:
registerRequestin interfacePacketTracerReadWorker- Parameters:
ltv- A message being sent that will generate a response from Packet Tracer
-
getResponse
Description copied from interface:PacketTracerReadWorkerBlocks the current Thread until a response message for ltv is received from Packet Tracer- Specified by:
getResponsein interfacePacketTracerReadWorker- Parameters:
ltv- The message whose response is desired- Returns:
- the response LTV received from Packet Tracer
-
shouldStop
public void shouldStop()Description copied from interface:PacketTracerReadWorkerCauses this worker to stop running. This may take effect immediately, or after an unspecified delay.- Specified by:
shouldStopin interfacePacketTracerReadWorker
-
run
public void run()This is the body of the Thread, in which this object does its work. It continually reads messages on the pipeline from Packet Tracer. If they're responses, it attempts to match the response (by message ID) with the request that generated it. It they're events, it forwards them to the event handler for additional processing. If they're neither responses nor events, or if they're responses with no request waiting on them, they're discarded with logging. -
discardUnmatchedResponse
Note a response message that had no matching requester. This is a hook for logging, as this is not necessarily an error condition ... it may be that another object wanted to send an IPC message and had no interest in what if any response came back.- Parameters:
ltv- The response message
-
discardUnknownMessage
Note a read message that's neither a response nor an event. This is a hook for logging, as this is not necessarily an error condition.- Parameters:
ltv- The unrecognized message
-
readKeepAlive
-